<?php 
namespace XFCore\controllers\api;
use lib\paysdk\payconf;
use lib\paysdk\PaySdk;
use lib\{XFCaptcha , Tips , AssetHandler , BaseController , Examine};
use XFCore\traits\ApiTraits;
class IndexController extends BaseController{
    use ApiTraits;
    protected $XFcaptcha;
    public function __construct() {
        parent::__construct();
        $this->XFcaptcha   = new XFCaptcha(CaptchaCode);
    }
    public function captcha(){
        $this->XFcaptcha->generateCaptcha();
    }
    //引入权限 需要配置相应的伪静态
    public function sysassets($path) {
        // 确保关闭任何输出缓冲
        while (ob_get_level()) {
            ob_end_clean();
        }
        if (empty($path)) {
            http_response_code(400);
            exit;
        }
    
        // 使用绝对路径
        $assetsPath = ROOT . '/includes/assets';
        
        try {
            $handler = new \lib\AssetHandler($assetsPath);
            $handler->handle($path);
        } catch (\Exception $e) {
            http_response_code(500);
        }
        exit;
    }
    
    public function usermenu(){
        @header('Content-Type: application/json; charset=UTF-8');
        $menujson = get_curl($this->httphost . 'assets/user/admin/data/menu.json');
        $jsondecode = json_decode($menujson,true);
        $hideIds = Examine::getHideIds();
        $jsondecode = Examine::removeMenuById($jsondecode, $hideIds);
        
        echo json_encode($jsondecode);
    }
    
    protected function decode_token($token){
        $decode = aes256auth($token,$this->Hang_Token,'DECODE');
        return json_decode($decode , true);
    }
    
   
}


?>